.netCHARTING v10.7 Documentation
Element Colors & Palettes

Introduction

This tutorial will describe how to use palettes and specify element and series colors as well as some more advanced coloring features.

 

Using Palettes

There are several 50 color palettes and over 40 5 color palettes available in the Palette enumeration. These can be defined in two ways.

A: Through Chart.PaletteName:

[C#]

Chart.PaletteName = dotnetCHARTING.Palette.Autumn;
[Visual Basic]

Chart.PaletteName = dotnetCHARTING.Palette.Autumn

 

This code will color each series based on a color in this palette.

B: Through Series.PaletteName

[C#]

mySeries.PaletteName = dotnetCHARTING.Palette.Autumn;
[Visual Basic]

mySeries.PaletteName = dotnetCHARTING.Palette.Autumn

Using palette properties of series will color each element in that series a unique color of the specified palette as well as alter the legend behavior.

NOTE: (Important) By specifying a series palette, the legend box will display an entry for each element instead of entries for each series.
Sample: ColorByElements.aspx

Custom Palettes

There are a number of five color palettes available in the Palette enumeration. These palettes can be combined to form a palette with a larger set of colors using the Chart.PaletteAdd() method.

Sample: MultiplePalettes.aspx

Custom palettes can also be specified by supplying the Chart.Palette or Series.Palette properties with an array of color objects. They will work in the same way as pre-defined palettes.

Coloring Individual Elements

To specify a color for an individual element it needs to be set through the Element.Color property. To specify a color for an entire series of elements, set the Series.DefaultElement.Color property.

In order to specify individual series or element colors, a populated Series or SeriesCollection is required. Please see this kb for more information.

 

Samples

  • iterateElements.aspx
    Color elements based on value.
  • InvisibleLegendEntry.aspx
    Color elements based on value.


SeriesTypeFinancial

Financial series types like candlestick and bar use Element.SecondaryColor to fill elements that have a lower close price than open price.

SeriesType.Line

A 2D line's thickness, and style can be controlled with the Series.Line property however, the line color is based on individual element colors.

More advanced coloring options are described in the SmartColor & SmartPalette Tutorial.